﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using ZX.HIS.IDAL;
using ZX.HIS.DBUtility;
using System.Collections.Generic;//Please add references
namespace ZX.HIS.SQLServerDAL
{
    /// <summary>
    /// 数据访问类:RegistInfo
    /// </summary>
    public partial class RegistInfo : IRegistInfo
    {
        public RegistInfo()
        { }
        #region 挂号信息保存表自写方法
        /// <summary>
        /// 返回挂号信息
        /// </summary>
        /// <returns></returns>
        public int RegistInfoTopRegistId(int DepartId, int UserIdOne, int HospitalId)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine(" SELECT TOP 1 RegistId FROM tbRegistInfo WHERE RegistState=0");
            if (UserIdOne != 0)
            {
                SQL.AppendLine(" AND UserIdOne=" + UserIdOne + "");
            }
            if (DepartId != 0)
            {
                SQL.AppendLine(" AND DepartId=" + DepartId + "");
            }
            if (HospitalId != 0)
            {
                SQL.AppendLine(" AND HospitalId=" + HospitalId);
            }
            SQL.AppendLine("  ORDER BY RegistId ASC");
            object obj = SqlDBhelper.ExecuteScalar(SQL.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 未就诊人数
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public int RegistInfoCount(int DepartId, int UserIdOne, int HospitalId)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine("SELECT COUNT(*) FROM ");
            SQL.AppendLine(" tbRegistInfo  WHERE RegistState=0");
            if (UserIdOne != 0)
            {
                SQL.AppendLine(" AND UserIdOne=" + UserIdOne + "");
            }
            if (DepartId != 0)
            {
                SQL.AppendLine(" AND DepartId=" + DepartId + "");
            }
            if (HospitalId != 0)
            {
                SQL.AppendLine(" AND HospitalId=" + HospitalId);
            }
            return SqlDBhelper.ExecuteScalarInt(SQL.ToString());
        }
        /// <summary>
        /// 当前诊所下的所有挂号信息
        /// </summary>
        /// <param name="HospitalId"></param>
        /// <returns></returns>
        public List<ZX.HIS.Model.RegistInfo> RegistInfoList(int HospitalId)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine("SELECT RegistId,RegistChiName  FROM ");
            SQL.AppendLine(" tbRegistInfo  WHERE 1=1");
            if (HospitalId != 0)
            {
                SQL.AppendLine(" AND HospitalId=" + HospitalId);
            }
            return SqlDBhelper.GetList<ZX.HIS.Model.RegistInfo>(SQL.ToString());
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZX.HIS.Model.RegistInfo RegistInfoGetModel(int RegistId)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.Append("SELECT  TOP 1 RegistId,HospitalId,RegistChiName,RegistSex,RegistAge,DepartId,UserIdOne");
            SQL.AppendLine(",RegistTypeId,RegistNoPrice,RegistRePrice,RegistHasPrice,RegistTime,UserIdTwo,RegistState from tbRegistInfo ");
            SQL.Append(" WHERE RegistId=@RegistId");
            SqlParameter[] parameters = {
                    new SqlParameter("@RegistId", SqlDbType.Int,32)
            };
            parameters[0].Value = RegistId;

            ZX.HIS.Model.RegistInfo model = new ZX.HIS.Model.RegistInfo();
            DataSet ds = SqlDBhelper.DataSetQuery(SQL.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZX.HIS.Model.RegistInfo DataRowToModel(DataRow row)
        {
            ZX.HIS.Model.RegistInfo model = new ZX.HIS.Model.RegistInfo();
            if (row != null)
            {
                if (row["RegistId"] != null && row["RegistId"].ToString() != "")
                {
                    model.RegistId = int.Parse(row["RegistId"].ToString());
                }
                if (row["HospitalId"] != null && row["HospitalId"].ToString() != "")
                {
                    model.HospitalId = int.Parse(row["HospitalId"].ToString());
                }
                if (row["RegistChiName"] != null)
                {
                    model.RegistChiName = row["RegistChiName"].ToString();
                }
                if (row["RegistSex"] != null && row["RegistSex"].ToString() != "")
                {
                    model.RegistSex = int.Parse(row["RegistSex"].ToString());
                }
                if (row["RegistAge"] != null && row["RegistAge"].ToString() != "")
                {
                    model.RegistAge = int.Parse(row["RegistAge"].ToString());
                }
                if (row["DepartId"] != null && row["DepartId"].ToString() != "")
                {
                    model.DepartId = int.Parse(row["DepartId"].ToString());
                }
                if (row["UserIdOne"] != null && row["UserIdOne"].ToString() != "")
                {
                    model.UserIdOne = int.Parse(row["UserIdOne"].ToString());
                }
                if (row["RegistTypeId"] != null && row["RegistTypeId"].ToString() != "")
                {
                    model.RegistTypeId = int.Parse(row["RegistTypeId"].ToString());
                }
                if (row["RegistNoPrice"] != null && row["RegistNoPrice"].ToString() != "")
                {
                    model.RegistNoPrice = decimal.Parse(row["RegistNoPrice"].ToString());
                }
                if (row["RegistRePrice"] != null && row["RegistRePrice"].ToString() != "")
                {
                    model.RegistRePrice = decimal.Parse(row["RegistRePrice"].ToString());
                }
                if (row["RegistHasPrice"] != null && row["RegistHasPrice"].ToString() != "")
                {
                    model.RegistHasPrice = decimal.Parse(row["RegistHasPrice"].ToString());
                }
                if (row["RegistTime"] != null && row["RegistTime"].ToString() != "")
                {
                    model.RegistTime = DateTime.Parse(row["RegistTime"].ToString());
                }
                if (row["UserIdTwo"] != null && row["UserIdTwo"].ToString() != "")
                {
                    model.UserIdTwo = int.Parse(row["UserIdTwo"].ToString());
                }
                if (row["RegistState"] != null && row["RegistState"].ToString() != "")
                {
                    model.RegistState = int.Parse(row["RegistState"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 挂号信息分页查询
        /// </summary>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">每页条数</param>
        /// <param name="StrWhere">查询条件</param>
        /// <param name="StrOrder">排序条件</param>
        /// <returns></returns>
        public List<ZX.HIS.Model.RegistInfo> RegistInfoPageList(int PageIndex, int PageSize, ZX.HIS.Model.RegistInfo RIModel, string StrOrder)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine("SELECT * FROM (");
            SQL.AppendLine(" SELECT ROW_NUMBER() OVER(");
            if (!String.IsNullOrEmpty(StrOrder))
            {
                if (!String.IsNullOrEmpty(StrOrder.Trim()))
                {
                    SQL.AppendLine(" ORDER BY T." + StrOrder);
                }
            }
            else
            {
                SQL.AppendLine(" ORDER BY T.RegistId desc");
            }
            SQL.AppendLine(" )AS Row,T.RegistId,T.HospitalId,RegistChiName,RegistSex,RegistAge,T.DepartId,T.UserIdOne");
            SQL.AppendLine(",T.RegistTypeId,RegistNoPrice,RegistRePrice,RegistHasPrice,RegistState,RegistTime,T.UserIdTwo,");
            SQL.AppendLine("isnull(B.RegistTypeName,'未指定') RegistTypeName ,");
            SQL.AppendLine("isnull(C.DepartName,'未指定') DepartName,");
            SQL.AppendLine("isnull(D.UserChineseName,'未指定')  UserChineseNameOne ,E.UserChineseName UserChineseNameTwo ");
            SQL.AppendLine(" FROM tbRegistInfo T INNER JOIN tbRegistType B ON T.RegistTypeId = B.RegistTypeId");
            SQL.AppendLine(" LEFT JOIN tbDepartInfo C ON T.DepartId = C.DepartId ");
            SQL.AppendLine(" LEFT JOIN tbUserInfo D ON T.UserIdOne = D.UserId");
            SQL.AppendLine(" LEFT JOIN tbUserInfo E ON T.UserIdTwo = E.UserId  WHERE 1=1");
            if (!String.IsNullOrEmpty(RIModel.RegistChiName))
            {
                SQL.AppendLine(" AND T.RegistChiName LIKE '%" + RIModel.RegistChiName + "%'");
            }
            if (!String.IsNullOrEmpty(RIModel.UserNameOne))
            {
                SQL.AppendLine(" AND T.UserNameOne LIKE '%" + RIModel.UserNameOne + "%'");
            }
            SQL.AppendLine(" AND T.HospitalId=" + RIModel.HospitalId);
            SQL.AppendLine(") TT");
            SQL.AppendLine(" WHERE TT.Row between " + ((PageIndex - 1) * PageSize + 1) + " AND " + PageIndex * PageSize);
            return SqlDBhelper.GetList<ZX.HIS.Model.RegistInfo>(SQL.ToString());
        }
        /// <summary>
        /// 分页总条数
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public int RegistInfoCount(ZX.HIS.Model.RegistInfo RIModel)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine("SELECT COUNT(*) FROM ");
            SQL.AppendLine(" tbRegistInfo T INNER JOIN tbRegistType B ON T.RegistTypeId = B.RegistTypeId");
            SQL.AppendLine(" LEFT JOIN tbDepartInfo C ON T.DepartId = C.DepartId ");
            SQL.AppendLine(" LEFT JOIN tbUserInfo D ON T.UserIdOne = D.UserId WHERE 1=1");
            if (!String.IsNullOrEmpty(RIModel.RegistChiName))
            {
                SQL.AppendLine(" T.RegistChiName LIKE '%" + RIModel.RegistChiName + "%'");
            }
            if (!String.IsNullOrEmpty(RIModel.UserNameOne))
            {
                SQL.AppendLine(" T.RegistChiName LIKE '%" + RIModel.RegistChiName + "%'");
            }
            SQL.AppendLine(" AND T.HospitalId=" + RIModel.HospitalId);
            return SqlDBhelper.ExecuteScalarInt(SQL.ToString());
        }
        /// <summary>
        /// 添加挂号
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public bool RegistInfoAdd(ZX.HIS.Model.RegistInfo RIModel)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine(" INSERT INTO tbRegistInfo  ");
            SQL.AppendLine("(HospitalId,RegistChiName,RegistSex,RegistAge,DepartId,UserIdOne,RegistTypeId,RegistNoPrice");
            SQL.AppendLine(",RegistRePrice,RegistHasPrice,RegistTime,UserIdTwo,RegistState)");
            SQL.AppendLine(" VALUES ");
            SQL.AppendLine(" (@HospitalId,@RegistChiName,@RegistSex,@RegistAge,@DepartId,@UserIdOne,@RegistTypeId,@RegistNoPrice");
            SQL.AppendLine(",@RegistRePrice,@RegistHasPrice,@RegistTime,@UserIdTwo,@RegistState)");
            SqlParameter[] parameters ={
                    new SqlParameter("@HospitalId", SqlDbType.Int),
                    new SqlParameter("@RegistChiName", SqlDbType.VarChar),
                    new SqlParameter("@RegistSex", SqlDbType.Int),
                    new SqlParameter("@RegistAge", SqlDbType.Int),
                    new SqlParameter("@DepartId", SqlDbType.Int),
                    new SqlParameter("@UserIdOne", SqlDbType.Int),
                    new SqlParameter("@RegistTypeId", SqlDbType.Int),
                    new SqlParameter("@RegistNoPrice", SqlDbType.Decimal),
                    new SqlParameter("@RegistRePrice", SqlDbType.Decimal),
                    new SqlParameter("@RegistHasPrice", SqlDbType.Decimal),
                    new SqlParameter("@RegistTime", SqlDbType.DateTime),
                    new SqlParameter("@UserIdTwo", SqlDbType.Int),
                    new SqlParameter("@RegistState",SqlDbType.Int)
                                      };
            parameters[0].Value = RIModel.HospitalId;
            parameters[1].Value = RIModel.RegistChiName;
            parameters[2].Value = RIModel.RegistSex;
            parameters[3].Value = RIModel.RegistAge;
            parameters[4].Value = RIModel.DepartId;
            parameters[5].Value = RIModel.UserIdOne;
            parameters[6].Value = RIModel.RegistTypeId;
            parameters[7].Value = RIModel.RegistNoPrice;
            parameters[8].Value = RIModel.RegistRePrice;
            parameters[9].Value = RIModel.RegistHasPrice;
            parameters[10].Value = DateTime.Now;
            parameters[11].Value = RIModel.UserIdTwo;
            parameters[12].Value = 0;
            int i = SqlDBhelper.ExecuteNonQuery(SQL.ToString(), parameters);
            if (i > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 修改挂号信息
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public bool RegistInfoUpt(ZX.HIS.Model.RegistInfo RIModel)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine(" UPDATE  tbRegistInfo  SET");
            SQL.AppendLine(" DepartId=@DepartId,UserIdOne=@UserIdOne,RegistState=@RegistState,");
            SQL.AppendLine("RegistChiName=@RegistChiName,RegistSex=@RegistSex,RegistAge=@RegistAge,RegistTypeId=");
            SQL.AppendLine("@RegistTypeId,RegistNoPrice=@RegistNoPrice,RegistRePrice=@RegistRePrice,RegistHasPrice=@RegistHasPrice");
            SQL.AppendLine(" WHERE RegistId=@RegistId");
            SqlParameter[] parameters ={
                    new SqlParameter("@DepartId", SqlDbType.Int){Value=RIModel.DepartId},
                    new SqlParameter("@UserIdOne", SqlDbType.Int){Value=RIModel.UserIdOne},
                    new SqlParameter("@RegistState", SqlDbType.Int){Value=RIModel.RegistState},
                    new SqlParameter("@RegistChiName",SqlDbType.VarChar){Value=RIModel.RegistChiName},
                     new SqlParameter("@RegistSex", SqlDbType.Int){Value=RIModel.RegistSex},
                    new SqlParameter("@RegistAge", SqlDbType.Int){Value=RIModel.RegistAge},
                    new SqlParameter("@RegistTypeId", SqlDbType.Int){Value=RIModel.RegistTypeId},
                    new SqlParameter("@RegistNoPrice",SqlDbType.Decimal){Value=RIModel.RegistNoPrice},
                     new SqlParameter("@RegistRePrice", SqlDbType.Decimal){Value=RIModel.RegistRePrice},
                    new SqlParameter("@RegistHasPrice", SqlDbType.Decimal){Value=RIModel.RegistHasPrice},
                    new SqlParameter("@RegistId", SqlDbType.Int){Value=RIModel.RegistId}
                                      };
            int i = SqlDBhelper.ExecuteNonQuery(SQL.ToString(), parameters);
            if (i > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="RegistId"></param>
        /// <param name="RegistState"></param>
        /// <returns></returns>
        public bool RegistInfoUpt(int RegistId,int RegistState)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine(" UPDATE  tbRegistInfo  SET");
            SQL.AppendLine(" RegistState=@RegistState");
            SQL.AppendLine(" WHERE RegistId=@RegistId");
            SqlParameter[] parameters ={
                    new SqlParameter("@RegistId", SqlDbType.Int){Value=RegistId},
                    new SqlParameter("@RegistState", SqlDbType.Int){Value=RegistState}
                                      };
            int i = SqlDBhelper.ExecuteNonQuery(SQL.ToString(), parameters);
            if (i > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 获得用户表数据列表
        /// </summary>
        /// <param name="HospitalId">医院id</param>
        /// <param name="DepartId">科室id</param>
        /// <returns></returns>
        public List<ZX.HIS.Model.UserInfo> GetUserList(int HospitalId, int DepartId)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.Append("SELECT UserId,UserName,UserChineseName ");
            SQL.Append(" FROM tbUserInfo WHERE 1=1");
            if (HospitalId != 0)
            {
                SQL.AppendLine(" AND HospitalId=" + HospitalId + "");
            }
            if (DepartId != 0)
            {
                SQL.AppendLine(" AND DepartId=" + DepartId + "");
            }
            return SqlDBhelper.GetList<ZX.HIS.Model.UserInfo>(SQL.ToString());
        }
        #endregion
        #region  BasicMethod

        ///// <summary>
        ///// 得到最大ID
        ///// </summary>
        //public int GetMaxId()
        //{
        //return DbHelperSQL.GetMaxID("RegistId", "tbRegistInfo"); 
        //}

        ///// <summary>
        ///// 是否存在该记录
        ///// </summary>
        //public bool Exists(int RegistId)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select count(1) from tbRegistInfo");
        //    strSql.Append(" where RegistId=@RegistId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@RegistId", SqlDbType.Int),

        //    };
        //    parameters[0].Value = RegistId;

        //    return DbHelperSQL.Exists(strSql.ToString(),parameters);
        //}


        ///// <summary>
        ///// 增加一条数据
        ///// </summary>
        //public int Add(ZX.HIS.Model.RegistInfo model)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("insert into tbRegistInfo(");
        //    strSql.Append("");
        //    strSql.Append(" values (");
        //    strSql.Append("@HospitalId,@RegistChiName,@RegistSex,@RegistAge,@DepartId,@UserIdOne,@RegistTypeId,@RegistNoPrice,@RegistRePrice,@RegistHasPrice,@RegistTime,@UserIdTwo)");
        //    strSql.Append(";select @@IDENTITY");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@HospitalId", SqlDbType.Int,4),
        //            new SqlParameter("@RegistChiName", SqlDbType.VarChar,50),
        //            new SqlParameter("@RegistSex", SqlDbType.Int,4),
        //            new SqlParameter("@RegistAge", SqlDbType.Int,4),
        //            new SqlParameter("@DepartId", SqlDbType.Int,4),
        //            new SqlParameter("@UserIdOne", SqlDbType.Int,4),
        //            new SqlParameter("@RegistTypeId", SqlDbType.Int,4),
        //            new SqlParameter("@RegistNoPrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@RegistRePrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@RegistHasPrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@RegistTime", SqlDbType.date,3),
        //            new SqlParameter("@UserIdTwo", SqlDbType.Int,4)};
        //    parameters[0].Value = model.HospitalId;
        //    parameters[1].Value = model.RegistChiName;
        //    parameters[2].Value = model.RegistSex;
        //    parameters[3].Value = model.RegistAge;
        //    parameters[4].Value = model.DepartId;
        //    parameters[5].Value = model.UserIdOne;
        //    parameters[6].Value = model.RegistTypeId;
        //    parameters[7].Value = model.RegistNoPrice;
        //    parameters[8].Value = model.RegistRePrice;
        //    parameters[9].Value = model.RegistHasPrice;
        //    parameters[10].Value = model.RegistTime;
        //    parameters[11].Value = model.UserIdTwo;

        //    object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
        //    if (obj == null)
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        return Convert.ToInt32(obj);
        //    }
        //}
        ///// <summary>
        ///// 更新一条数据
        ///// </summary>
        //public bool Update(ZX.HIS.Model.RegistInfo model)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("update tbRegistInfo set ");
        //    strSql.Append("HospitalId=@HospitalId,");
        //    strSql.Append("RegistChiName=@RegistChiName,");
        //    strSql.Append("RegistSex=@RegistSex,");
        //    strSql.Append("RegistAge=@RegistAge,");
        //    strSql.Append("DepartId=@DepartId,");
        //    strSql.Append("UserIdOne=@UserIdOne,");
        //    strSql.Append("RegistTypeId=@RegistTypeId,");
        //    strSql.Append("RegistNoPrice=@RegistNoPrice,");
        //    strSql.Append("RegistRePrice=@RegistRePrice,");
        //    strSql.Append("RegistHasPrice=@RegistHasPrice,");
        //    strSql.Append("RegistTime=@RegistTime,");
        //    strSql.Append("UserIdTwo=@UserIdTwo");
        //    strSql.Append(" where RegistId=@RegistId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@HospitalId", SqlDbType.Int,4),
        //            new SqlParameter("@RegistChiName", SqlDbType.VarChar,50),
        //            new SqlParameter("@RegistSex", SqlDbType.Int,4),
        //            new SqlParameter("@RegistAge", SqlDbType.Int,4),
        //            new SqlParameter("@DepartId", SqlDbType.Int,4),
        //            new SqlParameter("@UserIdOne", SqlDbType.Int,4),
        //            new SqlParameter("@RegistTypeId", SqlDbType.Int,4),
        //            new SqlParameter("@RegistNoPrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@RegistRePrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@RegistHasPrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@RegistTime", SqlDbType.date,3),
        //            new SqlParameter("@UserIdTwo", SqlDbType.Int,4),
        //            new SqlParameter("@RegistId", SqlDbType.Int,4)};
        //    parameters[0].Value = model.HospitalId;
        //    parameters[1].Value = model.RegistChiName;
        //    parameters[2].Value = model.RegistSex;
        //    parameters[3].Value = model.RegistAge;
        //    parameters[4].Value = model.DepartId;
        //    parameters[5].Value = model.UserIdOne;
        //    parameters[6].Value = model.RegistTypeId;
        //    parameters[7].Value = model.RegistNoPrice;
        //    parameters[8].Value = model.RegistRePrice;
        //    parameters[9].Value = model.RegistHasPrice;
        //    parameters[10].Value = model.RegistTime;
        //    parameters[11].Value = model.UserIdTwo;
        //    parameters[12].Value = model.RegistId;

        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        ///// <summary>
        ///// 删除一条数据
        ///// </summary>
        //public bool Delete(int RegistId)
        //{

        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("delete from tbRegistInfo ");
        //    strSql.Append(" where RegistId=@RegistId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@RegistId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = RegistId;

        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
        ///// <summary>
        ///// 批量删除数据
        ///// </summary>
        //public bool DeleteList(string RegistIdlist )
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("delete from tbRegistInfo ");
        //    strSql.Append(" where RegistId in ("+RegistIdlist + ")  ");
        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}


        ///// <summary>
        ///// 得到一个对象实体
        ///// </summary>
        //public ZX.HIS.Model.RegistInfo GetModel(int RegistId)
        //{

        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select  top 1 RegistId,HospitalId,RegistChiName,RegistSex,RegistAge,DepartId,UserIdOne,RegistTypeId,RegistNoPrice,RegistRePrice,RegistHasPrice,RegistTime,UserIdTwo from tbRegistInfo ");
        //    strSql.Append(" where RegistId=@RegistId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@RegistId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = RegistId;

        //    ZX.HIS.Model.RegistInfo model=new ZX.HIS.Model.RegistInfo();
        //    DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
        //    if(ds.Tables[0].Rows.Count>0)
        //    {
        //        return DataRowToModel(ds.Tables[0].Rows[0]);
        //    }
        //    else
        //    {
        //        return null;
        //    }
        //}


        ///// <summary>
        ///// 得到一个对象实体
        ///// </summary>
        //public ZX.HIS.Model.RegistInfo DataRowToModel(DataRow row)
        //{
        //    ZX.HIS.Model.RegistInfo model=new ZX.HIS.Model.RegistInfo();
        //    if (row != null)
        //    {
        //        if(row["RegistId"]!=null && row["RegistId"].ToString()!="")
        //        {
        //            model.RegistId=int.Parse(row["RegistId"].ToString());
        //        }
        //        if(row["HospitalId"]!=null && row["HospitalId"].ToString()!="")
        //        {
        //            model.HospitalId=int.Parse(row["HospitalId"].ToString());
        //        }
        //        if(row["RegistChiName"]!=null)
        //        {
        //            model.RegistChiName=row["RegistChiName"].ToString();
        //        }
        //        if(row["RegistSex"]!=null && row["RegistSex"].ToString()!="")
        //        {
        //            model.RegistSex=int.Parse(row["RegistSex"].ToString());
        //        }
        //        if(row["RegistAge"]!=null && row["RegistAge"].ToString()!="")
        //        {
        //            model.RegistAge=int.Parse(row["RegistAge"].ToString());
        //        }
        //        if(row["DepartId"]!=null && row["DepartId"].ToString()!="")
        //        {
        //            model.DepartId=int.Parse(row["DepartId"].ToString());
        //        }
        //        if(row["UserIdOne"]!=null && row["UserIdOne"].ToString()!="")
        //        {
        //            model.UserIdOne=int.Parse(row["UserIdOne"].ToString());
        //        }
        //        if(row["RegistTypeId"]!=null && row["RegistTypeId"].ToString()!="")
        //        {
        //            model.RegistTypeId=int.Parse(row["RegistTypeId"].ToString());
        //        }
        //        if(row["RegistNoPrice"]!=null && row["RegistNoPrice"].ToString()!="")
        //        {
        //            model.RegistNoPrice=decimal.Parse(row["RegistNoPrice"].ToString());
        //        }
        //        if(row["RegistRePrice"]!=null && row["RegistRePrice"].ToString()!="")
        //        {
        //            model.RegistRePrice=decimal.Parse(row["RegistRePrice"].ToString());
        //        }
        //        if(row["RegistHasPrice"]!=null && row["RegistHasPrice"].ToString()!="")
        //        {
        //            model.RegistHasPrice=decimal.Parse(row["RegistHasPrice"].ToString());
        //        }
        //        if(row["RegistTime"]!=null && row["RegistTime"].ToString()!="")
        //        {
        //            model.RegistTime=DateTime.Parse(row["RegistTime"].ToString());
        //        }
        //        if(row["UserIdTwo"]!=null && row["UserIdTwo"].ToString()!="")
        //        {
        //            model.UserIdTwo=int.Parse(row["UserIdTwo"].ToString());
        //        }
        //    }
        //    return model;
        //}

        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public DataSet GetList(string strWhere)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select RegistId,HospitalId,RegistChiName,RegistSex,RegistAge,DepartId,UserIdOne,RegistTypeId,RegistNoPrice,RegistRePrice,RegistHasPrice,RegistTime,UserIdTwo ");
        //    strSql.Append(" FROM tbRegistInfo ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///// <summary>
        ///// 获得前几行数据
        ///// </summary>
        //public DataSet GetList(int Top,string strWhere,string filedOrder)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select ");
        //    if(Top>0)
        //    {
        //        strSql.Append(" top "+Top.ToString());
        //    }
        //    strSql.Append(" RegistId,HospitalId,RegistChiName,RegistSex,RegistAge,DepartId,UserIdOne,RegistTypeId,RegistNoPrice,RegistRePrice,RegistHasPrice,RegistTime,UserIdTwo ");
        //    strSql.Append(" FROM tbRegistInfo ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    strSql.Append(" order by " + filedOrder);
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///// <summary>
        ///// 获取记录总数
        ///// </summary>
        //public int GetRecordCount(string strWhere)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select count(1) FROM tbRegistInfo ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    object obj = DbHelperSQL.GetSingle(strSql.ToString());
        //    if (obj == null)
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        return Convert.ToInt32(obj);
        //    }
        //}
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("SELECT * FROM ( ");
        //    strSql.Append(" SELECT ROW_NUMBER() OVER (");
        //    if (!string.IsNullOrEmpty(orderby.Trim()))
        //    {
        //        strSql.Append("order by T." + orderby );
        //    }
        //    else
        //    {
        //        strSql.Append("order by T.RegistId desc");
        //    }
        //    strSql.Append(")AS Row, T.*  from tbRegistInfo T ");
        //    if (!string.IsNullOrEmpty(strWhere.Trim()))
        //    {
        //        strSql.Append(" WHERE " + strWhere);
        //    }
        //    strSql.Append(" ) TT");
        //    strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///*
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@tblName", SqlDbType.VarChar, 255),
        //            new SqlParameter("@fldName", SqlDbType.VarChar, 255),
        //            new SqlParameter("@PageSize", SqlDbType.Int),
        //            new SqlParameter("@PageIndex", SqlDbType.Int),
        //            new SqlParameter("@IsReCount", SqlDbType.Bit),
        //            new SqlParameter("@OrderType", SqlDbType.Bit),
        //            new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
        //            };
        //    parameters[0].Value = "tbRegistInfo";
        //    parameters[1].Value = "RegistId";
        //    parameters[2].Value = PageSize;
        //    parameters[3].Value = PageIndex;
        //    parameters[4].Value = 0;
        //    parameters[5].Value = 0;
        //    parameters[6].Value = strWhere;	
        //    return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        //}*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

